package review;

import java.io.IOException;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Create By IntelliJ IDEA
 *
 * @Author: jsonor
 * @Create-Time: 2017/10/12 8:15
 * @Description: ServletContext的域访问
 */

@WebServlet(name = "context", urlPatterns = {"/context"})
public class ContextServlet extends HttpServlet {

  @Override
  protected void doGet(HttpServletRequest request,
      HttpServletResponse response)
      throws ServletException, IOException {
    ServletContext context = this.getServletContext();
    Object name = context.getAttribute("name");

    response.getWriter().println("context servlet get context key = name, value = " + name);
  }
}
